﻿@model IEnumerable<HotelManageSystem.Models.WageModelOutline>
<link href= "@Url.Content("~/Content/TelerikGrid.css")"rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $(".WageSet").click(function () {
            var employeeId = $(this).attr("employeeId");
            $.get("/Wage/WageSet/" + employeeId, null, function (data) {
                $("#content").html(data);
            });
            //设置当前位置为/Wage/WageSet,防止刷新跳转到Wage/WageSetIndex
            $.post("HumanResources/SetSeesion", { u: "/Wage/WageSet/" + employeeId }, function () { });
        });

        $(".WageGrant").click(function () {
            var employeeId = $(this).attr("employeeId");
            $.get("/Wage/WageGrant/" + employeeId, null, function (data) {
                $("#content").html(data);
            });
            //设置当前位置为/Wage/WageGrant,防止刷新跳转到Wage/WageSetIndex
            $.post("HumanResources/SetSeesion", { u: "/Wage/WageGrant/" + employeeId }, function () { });
        });
    });

    //防止Telerik控件经过排序、分页后,新增功能脚本失效
    function onDataBound() {
        $(".WageSet").click(function () {
            var employeeId = $(this).attr("employeeId");
            $.get("/Wage/WageSet/" + employeeId, null, function (data) {
                $("#content").html(data);
            });
            //设置当前位置为/Wage/WageSet/,防止刷新跳转到Wage/WageSetIndex
            $.post("HumanResources/SetSeesion", { u: "/Wage/WageSet/" + employeeId }, function () { });
        });

        $(".WageGrant").click(function () {
            var employeeId = $(this).attr("employeeId");
            $.get("/Wage/WageGrant/" + employeeId, null, function (data) {
                $("#content").html(data);
            });
            //设置当前位置为/Wage/WageGrant,防止刷新跳转到Wage/WageSetIndex
            $.post("HumanResources/SetSeesion", { u: "/Wage/WageGrant/" + employeeId }, function () { });
        });
    }
</script>
@(
 Html.Telerik().Grid(Model)
        .Name("WageSetIndexGrid")
        .DataKeys(keys => keys.Add(w => w.EmployeeId))
        .DataBinding(dataBinding => dataBinding.Ajax()
            .Select("WageSetIndexAjax", "Wage"))
        .Sortable(sorting => sorting
            .SortMode(GridSortMode.SingleColumn))
        .Pageable(paging => paging
            .Style(GridPagerStyles.NextPreviousAndNumeric)
            .Position(GridPagerPosition.Bottom)
            .PageSize(12))
        .Columns(columns =>
        {
            columns.Bound(w => w.EmployeeId);
            columns.Bound(w => w.Name);
            columns.Bound(w => w.Department);
            columns.Bound(w => w.Post);
            columns.Bound(w => w.BasicWage).Filterable(false).Format("{0:N}").Sortable(false);
            columns.Bound(w => w.BasicValue).Filterable(false).Format("{0:N}").Sortable(false);
            columns.Template(b => @Html.Raw("<input class='WageSet' type='button' value='工资设置' " +
                                            "employeeId='" + b.EmployeeId + "'/>" +
                                            "<input class='WageGrant' type='button' value='发放登记' " +
                                            "employeeId='" + b.EmployeeId + "'/>"))
                            .ClientTemplate("<input class='WageSet' type='button' value='工资设置' " +
                                            "employeeId='<#= EmployeeId #>'/>" +
                                            "<input class='WageGrant' type='button' value='发放登记' " +
                                            "employeeId='<#= EmployeeId #>'/>");
        })
        .Selectable()
        .Filterable()
        .ClientEvents(events => events//防止排序、过滤操作之后按钮无法调用脚本
                         .OnDataBound("onDataBound")
                     )
)
